home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_1 / easyprocess / source / launch / childentry.c < prev    next >
C/C++ Source or Header  |  1992-09-07  |  1KB  |  66 lines

  1. #include <arpbase.h>
  2. #include <arp_proto.h>
  3. #include "Launch.h"
  4. #include "LaunchPriv.h"
  5.  
  6.  
  7. /*
  8.  *    NAME
  9.  *        ChildEntry -- used when starting processes.
  10.  *
  11.  *    SYNOPSIS
  12.  *        ChildEntry ()
  13.  *
  14.  *    FUNCTION
  15.  *        Call the process' entry point with its data.
  16.  *
  17.  *    DESCRIPTION
  18.  *        It load the A4 register, find the process pair (parent/child),
  19.  *        allocate the child's kill signal and then call the child entry
  20.  *        point with the data given by the parent.  On exit, it clears
  21.  *        the entry point and signal the parent.
  22.  *
  23.  *    INPUT
  24.  *        None.
  25.  *
  26.  *    OUTPUT
  27.  *        None.
  28.  *
  29.  *    NOTE
  30.  *        We currently use the break C signal as the kill signal.  This
  31.  *        let the user kill the process himself (if anything should go
  32.  *        wrong...).
  33.  *
  34.  *    HISTORY
  35.  *        1992/09/06    Pierre Baillargeon        Creation
  36.  *        1992/09/07    Pierre Baillargeon        Correction
  37.  *                    Now, the node removal and memory freeing is done
  38.  *                    in the parent.  Otherwise the parent signal bit
  39.  *                    would not always be freed.
  40.  *
  41.  *    SEE ALSO
  42.  *        StartProcess()
  43.  */
  44.  
  45. void __saveds ChildEntry (void)
  46. {
  47.     struct ProcPair *pp;
  48.     struct Process *Proc;
  49.  
  50.     Proc = (struct Process *)FindTask (NULL);
  51.     Wait (1L << Proc->pr_MsgPort.mp_SigBit);
  52.  
  53.     Forbid ();
  54.     pp = IsChild (Proc);
  55.     Permit ();
  56.  
  57.     if (pp)
  58.     {
  59.         pp->pp_ChildBit = AllocSignal (KILL_PROCESS_FLAG);
  60.         pp->pp_ChildEntry (pp->pp_ChildData);
  61.         Forbid ();
  62.         pp->pp_ChildEntry = NULL;
  63.         Signal (pp->pp_Parent, 1L << pp->pp_ParentBit);
  64.     }
  65. }
  66.